﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Aulac.Srv.Db.Connect;
using System.Xml;
using Aulac.Global.Common;
using Aulac.Global.Xml;
using System.Data;
using Aulac.Global.Data;
using Aulac.Srv.Db.Common;
using Aulac.Rsc.Bss.Tags;
using Aulac.Rsc.Bss;

namespace Aulac.Srv.Db.Data.Ems.Items
{
    public class RptListItem: Aulac.Srv.Db.Data.Ems.Document.DbEmsDataDocumentMangager
    {
         public RptListItem(IDbAulacConnect p_Db)
            : base(p_Db)
        {

        }


         #region RptList
         public XmlDataDocument AddVchBuyList(XmlDataDocument xmlDoc)
         {

             XmlElement eHeader = XmlProcess.GetVchHeaderElm(xmlDoc);

             List<string> arr = new List<string>(new string[] { tagVch.VchBuyList.VchBuyPrkID, tagVch.VchBuyList.VchBuyID, tagVch.VchBuyList.VchBuyName, tagVch.VchBuyList.VchDateFrom, tagVch.VchBuyList.VchDateTo });
             sqlQuery = SqlHelper.CreateSqlInsert(TableNames.Dm_VchBuyList, arr);
             DbDataProvider.AddParamToCmd(mDbCmd, eHeader, arr.ToArray());
             DbDataProvider.ExecuteNonQuery(ref mDbCmd, sqlQuery);
             string sVchBuyPrkID = DbDataProvider.SelectMaxID(TableNames.Dm_VchBuyList, tagVch.VchBuyList.VchBuyPrkID);
             return xmlDoc;
         }

         public XmlDataDocument UpdateRtList(XmlDataDocument xmlDoc)
         {
             // code o day
             return null;
         }

         public XmlDataDocument DelVchBuyList(XmlDataDocument xmlDoc)
         {
             string sVchBuyPrkID = XmlProcess.GetValueParam(xmlDoc, tagVch.VchBuyList.VchBuyPrkID);
             DelDbTableVchBuy(RptListInfo.mTbVchBuyList, tagVch.VchBuyList.VchBuyPrkID, sVchBuyPrkID);
             //DelDbTableVchBuy(RptListInfo.mTbRptParam, tagItems.RptParams.RptPrkID, sRptPrkID);
             XmlDataDocument xmlData = XmlProcess.CreateXmlDocument("", "", Aulac.Global.Enums.SqlDateFormats.dmy);
             XmlElement eHeader = XmlProcess.SetVchHeaderElm(ref xmlData);
             XmlProcess.SetAtrb(ref eHeader, tagVch.VchBuyList.VchBuyPrkID, sVchBuyPrkID);
             return xmlData;
         }

         private void DelDbTableVchBuy(string p, string p_2, string sVchBuyPrkID)
         {
             throw new NotImplementedException();
         }
         #endregion
    }
}
